import { defineStore } from "pinia";

// const state = localStorage.getItem("app");

export const useAppStore = defineStore("app", {
  // state: () => {
  //   return state
  //     ? JSON.parse(state)
  //     : {
  //         count: 1,
  //         msg: "~",
  //       };
  // },

  state: () => ({
    count: 1,
    msg: "~",
  }),

  getters: {
    getCount(state) {
      return state.count;
    },
  },

  actions: {
    setCount(payload: number) {
      this.count = payload;
    },
  },

  /**
   * 自定义一些选项，这里为了实现一个是否要对当前仓库的state数据做持久化存储
   */
  needSave: true,
});
